package com.peng.dao.impl;

import com.peng.dao.agencyDao;
import com.peng.entity.agency;
import com.peng.util.BaseDao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by 欧阳欣鹏 on 2018/8/6.
 */
public class agencyDaoImpl implements agencyDao {

    @Override
    public List<agency> li(int id) {
        List<agency> li=new ArrayList<agency>();
        String sql="select * from agency where agencyid=?";
        Connection con=null;
        PreparedStatement st=null;
        ResultSet rs=null;
        try {
            con= BaseDao.getConnection();
            st=con.prepareStatement(sql);
            st.setInt(1,id);
            rs=st.executeQuery();
            while (rs.next()) {
                agency a=new agency();
               a.setAgencyid(rs.getInt("agencyid"));
               a.setUid(rs.getInt("uid"));
               a.setDrank(rs.getInt("drank"));
               a.setAffiliating(rs.getInt("affiliating"));
                li.add(a);
            }
        } catch (Exception e) {
            // TODO: handle exception
        }finally{
            BaseDao.closeConnection(con, st, rs);
        }
        return li;
    }
}
